package pl.edu.agh.lab2.sr.playerClient;

import java.rmi.Naming;

import pl.edu.agh.lab2.sr.beans.ConfigReader;
import pl.edu.agh.lab2.sr.remoteInterfaces.IGameServer;

public class SamplePlayer {
	// private static final String battleshipServerObjectPath =
	// "rmi://127.0.0.1:1099/battleship";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if (args.length < 1) {
			System.err.println("missing nickname");
			return;
		}

		// if (System.getSecurityManager() == null) {
		// System.setSecurityManager(new SecurityManager());
		// }

		String battleshipServerObjectPath = ConfigReader.getServerObjectPath();
		System.out.println(ConfigReader.getServerObjectPath());
		String nick = args[0];
		IGameServer server;
		try {
			 server = (IGameServer) Naming.lookup(battleshipServerObjectPath);
			 PlayerConsoleImpl player = new PlayerConsoleImpl(server, nick);
			 player.handleRegister();
			 player.menuLoop();
		} catch (Exception e) {
			System.out.println(e.toString());
			System.exit(1);
		}

	}

}
